<?

include_once '../library/smarty/src/Smarty.class.php';

class Smutty_Template extends Smarty {

	function Smutty_Template() {

		$this->compile_dir = '../library/smarty/cache';
		$this->template_dir = '../application/views/';
		$this->plugins_dir[] = '../library/smarty/plugins/'; // smutty plugins
		$this->plugins_dir[] = '../application/plugins/'; // app plugins

		$this->assign( 'baseUrl', Smutty_Utils::getBaseUrl() );
	}

	function display( $file ) {

		$router = Smutty_Router::getInstance();

		// try to use controller shortcut for filenames, if it
		// fails then fall back on the filename
		$path = strtolower($router->getController()) . "/$file";
		if ( !file_exists("$this->template_dir$path") )
			$path = $file;

		parent::display( $path );

	}

}

?>